import Page
from Page import Personal
from Base.Base import Base
from selenium.webdriver.common.by import By


class PersonalEditInformationPage(Base):
    """
    个人中心修改个人信息界面
    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.information_home_btn = (By.XPATH, Personal.RESOURCE_ID.format("ivHome"))

        # 左侧的返回键
        self.information_back_btn = (By.XPATH, Personal.RESOURCE_ID.format('ivBack'))

        # 个人信息标题
        self.information_personal_title_text = (By.XPATH, Page.TEXT.format("修改个人信息"))

        # 名称标题
        self.information_name_title_text = (By.XPATH, Personal.name_title_text.format(""))

        # 名称
        self.information_name_text = (By.XPATH, Personal.name_text.format(""))

        # 性别标题
        self.information_sex_title_text = (By.XPATH, Personal.sex_title_text.format(""))

        # 性别
        self.information_sex_text = (By.XPATH, Personal.sex_text.format(""))

        # 年龄标题
        self.information_age_title_text = (By.XPATH, Personal.age_title_text.format(""))

        # 年龄
        self.information_age_text = (By.XPATH, Personal.age_text.format(""))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.information_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.information_back_btn)

    def get_personal_title(self):
        """
        获取个人信息标题

        :return:
        """
        return self.find_element_o(self.information_personal_title_text)

    def get_name_title(self, index=1):
        """
        获取名称标题

        :return:
        """
        self.information_name_title_text = (By.XPATH, Personal.name_title_text.format(index))
        return self.find_element_o(self.information_name_title_text)

    def click_name_title(self, index=1):
        """
        点击名称标题

        :return:
        """
        self.information_name_title_text = (By.XPATH, Personal.name_title_text.format(index))
        self.click_element(self.information_name_title_text)

    def get_name(self, index=2):
        """
        获取名称

        :return:
        """
        self.information_name_text = (By.XPATH, Personal.name_text.format(index))
        return self.find_element_o(self.information_name_text)

    def get_sex_title(self, index=1):
        """
        获取性别标题

        :return:
        """
        self.information_sex_title_text = (By.XPATH, Personal.sex_title_text.format(index))
        return self.find_element_o(self.information_sex_title_text)

    def click_sex_title(self, index=1):
        """
        点击性别标题

        :return:
        """
        self.information_sex_title_text = (By.XPATH, Personal.sex_title_text.format(index))
        self.click_element(self.information_sex_title_text)

    def get_sex(self, index=2):
        """
        获取性别

        :return:
        """
        self.information_sex_text = (By.XPATH, Personal.sex_text.format(index))
        return self.find_element_o(self.information_sex_text)

    def get_age_title(self, index=1):
        """
        获取年龄标题

        :return:
        """
        self.information_age_title_text = (By.XPATH, Personal.age_title_text.format(index))
        return self.find_element_o(self.information_age_title_text)

    def click_age_title(self, index=1):
        """
        点击年龄标题

        :return:
        """
        self.information_age_title_text = (By.XPATH, Personal.age_title_text.format(index))
        self.click_element(self.information_age_title_text)

    def get_age(self, index=2):
        """
        获取年龄

        :return:
        """
        self.information_age_text = (By.XPATH, Personal.age_text.format(index))
        return self.find_element_o(self.information_age_text)

    def is_display_personal_edit_information(self):
        """
        是否存在信息编辑页

        :return: bool
        """
        return self.is_display(self.information_personal_title_text)
